package com.yzc.controller;

import com.yzc.service.TOrdersService;
import com.yzc.util.ResultData;
import com.yzc.util.ReturnCodeEnum;
import com.yzc.vo.resp.RushOrdersVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.yzc.util.ReturnCodeEnum.RC999;

@RestController
@RequestMapping("/order")
public class RushOrdersController {
    @Autowired
    private TOrdersService tOrdersService;

    @GetMapping("/rushOrdersList")
    public ResultData<List<RushOrdersVo>> rushOrdersList() {
        return ResultData.success(tOrdersService.rushOrdersList());
    }

    @GetMapping("/rushOrderByVersion")
    public ResultData rushOrderByVersion(@RequestParam("id") Integer id,
                                         @RequestParam("userId") Integer userId) {
        try {
            tOrdersService.rushOrderByVersion(id, userId);
            return ResultData.success();
        }catch (Exception e) {
            String code = ReturnCodeEnum.RC999.getCode();
            String message = ReturnCodeEnum.RC999.getMessage();
            return ResultData.fail(code, message);
        }

    }

}
